<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>华富</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/common.css" />
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../../css/aui-pull-refresh.css" />
    <link rel="stylesheet" type="text/css" href="../../css/swiper.min.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
</head>
<style>


    /***index_product***/
    .index_product{
      width: 100%;
    }
    .index_product_con{
      width: 100%;
      padding:0.4rem;
    }
    .index_product_list{
      width: 100%;
      background: #fff;
      border-radius: 0.5rem;
      overflow: hidden;
      margin-bottom: 0.4rem;
    }
    .index_product_zi{
      padding: 1.3rem 0.9rem;
    }
    .index_product_zi h5{
      font-size: 1.3rem;
      line-height: 1.2;
      color: #0a0a0a;
      margin-bottom: 1.2rem;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
      overflow: hidden;
    }
    .index_product_zi h5 font{
      display: inline-block;
      line-height: 1.5rem;
      font-size: 1rem;
      color: #fff;
      background: #ed6a20;
      border-radius: 0.2rem;
      margin-right: 0.2rem;
      padding: 0 0.4rem;
      vertical-align: top;
    }
    .index_product_zi p{
      font-size: 1.5rem;
      color: #f01818;
      line-height: 1.2;
    }
    .index_product_zi p span{
      float: right;
      line-height: 2rem;
      font-size: 1.1rem;
      color: #666666;
      border: 1px solid #999;
      padding: 0 1rem;
      border-radius: 2rem;
      position: relative;
      top: -0.2rem;
    }
    /***index_product***/


    /***search_wap***/
    .search_wap{
      width: 100%;
      padding-top: 6.5rem;
    }
    .search_wap_con{
      width: 100%;
      padding: 1.5rem 1.3rem;
      background: #fff;
    }

    .index_product_search .index_h5{
      background: #f5f5f5;
    }
    .search_wap_list{
      margin-bottom: 0.9rem;
    }
    .search_wap_list h5{
      font-size: 1.4rem;
      color: #000;
      line-height: 1;
      margin-bottom: 1.5rem;
    }
    .search_wap_list h5 span{
      float: right;
    }
    .search_wap_list h5 span img{
      width: 1.4rem;
    }
    .search_wap_list>span{
      display: inline-block;
      line-height: 3.2rem;
      padding: 0 1.6rem;
      border-radius: 3.2rem;
      background: #f5f5f5;
      font-size: 1.3rem;
      color: #333;
      margin-right: 0.6rem;
      margin-bottom: 0.9rem;
    }

    /***search_wap***/

    .famousAll{/* padding: 0 1.3rem; */ padding-top: 6.5rem;}
.famousBox ul{display: flex; flex-wrap: wrap;}
.famousBox ul li{width: 50%; padding: 0.3rem;}
.famousImg{width: 100%; padding-top: 100%; background-size: cover;  background-position: center;}
.famousInner{background: #fff; box-shadow: 0 0 15px rgba(0, 0, 0, 0.1); border-radius: 5px; overflow: hidden;}
.famousBox{padding: 0.3rem;}
.famousTxt h2{font-size: 1.3rem; color: #0a0a0a;}
.famousTxt{text-align: center; padding: 1rem 0.5rem;}
.famousTxt p{font-size: 1.1rem; color: #666;}
.famousTxt .aui-btn{display: inline-block; width: auto; font-size: 1.1rem; color: #666; height: auto; border-radius: 500px; padding: 0.2rem 1rem; border-color: #c2c2c2; margin-top: 0.6rem;}
[v-cloak]{
  display: none
}

/***search_wap***/
.search_wap{
  position: fixed;
  width: 80%;
  margin-left:9%;
  margin-top: 0.2rem;
  z-index: 999;
  border-radius: 1rem;
  opacity:0.8;
}
.search_wap_con{
  width: 100%;
  padding: 1.5rem 1.3rem;
  background: #fff;
}
.search_wap_list{
  margin-bottom: 0.9rem;
}
.search_wap_list h5{
  font-size: 1.4rem;
  color: #000;
  line-height: 1;
  margin-bottom: 1.5rem;
}
.search_wap_list h5 span{
  float: right;
}
.search_wap_list h5 span img{
  width: 1.4rem;
}
.search_wap_list>span{
  display: inline-block;
  line-height: 3.2rem;
  padding: 0 1.6rem;
  border-radius: 3.2rem;
  background: #f5f5f5;
  font-size: 1.3rem;
  color: #333;
  margin-right: 0.6rem;
  margin-bottom: 0.9rem;
}
.aui-toast-content{
  color: #fff
}
</style>
<body>
<div id="app" style="background: #f5f5f5;" v-cloak>

  <!--search-->
  <div class="search search_search" style="z-index:99999">
    <div class="search_con">
      <div class="search_map" onclick="goBack()"><img src="../../image/back.png"></div>
      <div class="search_input">
        <input type="search" placeholder="搜索" id="inputText" @focus="openShow" v-model="keyMsg">
        <div class="search_ss"><img src="../../image/search_icon2.png"></div>
        <div class="search_sm"><img src="../../image/search_icon1.png"></div>
      </div>
      <div class="search_info">
        <img src="../../image/search_info.png">
        <span>5</span>
      </div>
    </div>
  </div>
  <!--/search-->
  <div class="search_wap" v-if="isShow">
    <div class="search_wap_con">
      <div class="search_wap_list">
        <h5>热门搜索 <span><img src="../../image/search_sx.png" @click="rehisty"></span></h5>
        <span  v-for="item in rehistory" @click="getFamous(item.keywords)">{{item.keywords}}</span>
      </div>
      <div class="search_wap_list">
        <h5>历史搜索 <span><img src="../../image/search_sc.png" @click="clearhistory"></span></h5>
        <span v-for="item in history" @click="getFamous(item.keywords)">{{item.keywords}}</span>

      </div>
    </div>
  </div>

  <div class="aui-refresh-content" @click="closeShow">

    <div class="famousAll">

      <div class="famousBox">
        <ul>
          <li v-for="item in famousList">
            <div class="famousInner">
              <div class="famousImg" :style="'background-image:url('+item.pic+')'"></div>
              <!-- <img class="famousImg" :src=item.pic alt=""> -->
              <div class="famousTxt">
                <h2>{{item.name}}</h2>
                <p>{{item.worktime}}</p>
                <div class="aui-btn aui-btn-block aui-btn-outlined aui-btn-sm" @click="lookMsg('famousDot','famousDot.html',item.id)">查看详情</div>
              </div>
            </div>
          </li>
        </ul>
      </div>

    </div>

  </div>


</div>
</body>
</html>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/zepto.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript" src="../../script/utils.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/aui-tab.js"></script>
<script type="text/javascript" src="../../script/aui-scroll.js"></script>
<script type="text/javascript" src="../../script/aui-pull-refresh.js"></script>
<script type="text/javascript" src="../../script/swiper.min.js"></script>
<!-- <script type="text/javascript" src="../../script/axios.min.js"></script>
<script type="text/javascript" src="../../script/axios-config.js"></script> -->
<script type="text/javascript" src="../../script/aui-toast.js"></script>


<script type="text/javascript">

  var app;
  apiready = function(){
    var toast = new auiToast({})
    app = new Vue({
        el: '#app',
        data: {
          famousList:[],
          allpage:1,
          page:1,
          isShow:false,
          history:[],
          rehistory:[],
          keyMsg:''
        },
        created: function() {
          var $_this=this;
          api.showProgress({
              title: '努力加载中...',
              text: '先喝杯茶...',
              modal: false
          });
          $_this.getFamous();

        },
        methods: {
          closeShow:function(){
             this.isShow = false
          },
          openShow:function(){
             this.isShow = true
          },
          //热搜
          rehisty:function(){
            var _this = this
            api.ajax({
                url: window.hurl.redsousuo,
                method: 'post',
                data: {
                    values:{}
                }
            },function(ret, err){
                if (ret) {
                  //console.log('热搜记录：'+ JSON.stringify( ret ) );
                   if(ret.status==1 || ret.status==0){
                     _this.rehistory = ret.data
                   }else{
                      toast.fail({
                        title:ret.info,
                        duration:1500
                      })
                   }
                } else {
                    alert( JSON.stringify( err ) );
                }
            });
          },
          //清除
          clearhistory:function(){
            var _this = this
            var data={
                token:$api.getStorage('token') || "",
                store_id :''
            }
            api.ajax({
                url: window.hurl.del_store_search_log,
                method: 'post',
                data: {
                    values:data
                }
            },function(ret, err){
                if (ret) {
                    console.log( JSON.stringify( ret ) );
                    api.toast({
                        msg: ret.info,
                        duration: 1000,
                        location: 'middle'
                    });
                    if(ret.status==1){
                      _this.historyMsg()
                    }

                } else {
                    alert( JSON.stringify( err ) );
                }
            });

          },
          //历史
          historyMsg:function(){
            var _this = this
            api.ajax({
                url: window.hurl.sousuo,
                method: 'post',
                data: {
                    values:{
                      token:$api.getStorage('token') || ""
                    }
                }
            },function(ret, err){
                if (ret) {
                  //console.log('历史记录：'+ JSON.stringify( ret ) );
                   if(ret.status==1 || ret.status==0){
                     _this.history = ret.data
                   }else{
                      toast.fail({
                        title:ret.info,
                        duration:1500
                      })
                   }
                } else {
                    alert( JSON.stringify( err ) );
                }
            });
          },
          //输入
          inputMsg:function(){
            var _this = this
            $("#inputText").on("keypress",function(e){
              console.log(e.keyCode)
                e.keyCode==13 ? _this.getFamous($('#inputText').val()) : ''
            })
          },

          //查看详情
          lookMsg:function(name,url,id){
            api.openWin({
                name: name,
                url: url,
                pageParam: {
                    id:id
                }
            });
          },
          getFamous:function(keyword){
            var _this=this;
            _this.keyMsg = keyword
            var data = {
              page:1,
              num:6,
              key:keyword,
              token:$api.getStorage('token') || "",
              type_id:2,
              seatype:4
            }
            api.ajax({
                url: window.hurl.celebrity,
                method: 'post',
                data: {
                    values:data
              }
            },function(res, err){
                if (res) {
                  if(res.status == 1){
                    console.log(JSON.stringify(res))
                    _this.famousList=res.data
                    _this.allpage = res.count
                  }else{
                      toast.fail({
                        title:res.info,
                        duration: 1000,

                      });
                  }
                } else {
                  toast.fail({
                    title:res.info,
                    duration: 1000,

                  });
                }
            });
          }

        },
        mounted: function () {
          var $_this = this
          api.hideProgress();
          setRefresh();
          this.inputMsg()
          this.historyMsg()
          this.rehisty()
          //检测到达底部添加下一页内容
          var scroll = new auiScroll({
              listen:true, //是否监听滚动高度，开启后将实时返回滚动高度
              distance:40 //判断到达底部的距离，isToBottom为true
          },function(ret){
              if (ret.isToBottom) {
                  $_this.page ++
                  if ($_this.page > $_this.allpage) {
                      $_this.page = $_this.allpage
                      return
                  }
                  api.ajax({
                    url: window.hurl.celebrity,
                    method: 'post',
                    data: {
                        values: {
                          page:$_this.page,
                          num:6,
                          key:$_this.keyMsg || '',
                          token:$api.getStorage('token') || "",
                          type_id:2,
                          seatype:4
                        }
                  },
                      timeout: 300,
                  }, function(ret, err) {
                      if (ret) {
                          //api.alert({ msg: JSON.stringify(ret) });
                          $_this.famousList = $_this.famousList.concat(ret.data)

                      } else {
                          api.alert({ msg: JSON.stringify(err) });
                      }
                  })
              }

          })

        }
      })

  }

  //刷新
  function setRefresh(){
      var pullRefresh = new auiPullToRefresh({
          container: document.querySelector('.aui-refresh-content'),
          triggerDistance: 100
      }, function(ret) {

          if (ret.status == "success") {
              setTimeout(function() {
                  pullRefresh.cancelLoading(); //刷新成功后调用此方法隐藏
              }, 1500)
          }
      })
  }


  function goBack(){
    api.closeWin({

    });
  }



</script>
